package bookExercise;

import java.io.*;

public class A19BufferedReader {
    public static void main(String[] args) {
        String[] str ={"你到底要干啥","我来吃饭的","那你吃什么"};
        File f =new File("D:\\aaa.txt");
        try{
            FileWriter fw = new FileWriter(f);
            BufferedWriter bw = new BufferedWriter(fw);
            for(int i =0 ;i<str.length;i++){
                bw.write(str[i]);
                bw.newLine();
            }
            bw.close();
            fw.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        try{
            FileReader fr = new FileReader(f);
            BufferedReader br =new BufferedReader(fr);
           String tmp =null;
           int i =1;
           while((tmp=br.readLine())!=null){
               System.out.println("第"+i+"行"+tmp);
               i++;
           }
           fr.close();
           br.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
